<%@ include file="/WEB-INF/views/taglib.jsp"%>
<h3>Asset Model Form</h3>
<form:form id="form" method="post" modelAttribute="assetTransaction" cssClass="simpleForm">
	<form:hidden path="assetType" />
	<div class="clear" style="height:1px">&nbsp;</div>
	<jsp:include page="/WEB-INF/views/message.jsp"></jsp:include>
	<fieldset><legend>Component Initial Balance</legend>
	
	
	<table id="systemCodeValueTable" class="gridSearch">
		<col width="15%">
		<col width="70%">
	 	<col width="15%">
		<thead>
			<tr>
				<th>Company Code</th>
				<th>Location</th>
				<th>Initial Balance Qty</th>
			</tr>
		</thead>
		<tbody>
			<c:choose>
				<c:when test="${not empty assetTransaction.assetTransactionItems}">
					<c:forEach items="${assetTransaction.assetTransactionItems}" var="item" varStatus="status">
						<tr>
							<td>${item.companyCode} </td>
							<td>${item.location.locationName}</td>
							<td align="center">${item.assetTransactionQuantity}</td>
						</tr>
					</c:forEach>
				</c:when>
				<c:otherwise>
					<c:forEach items="${globalLocation}" var="item" varStatus="status">
						<tr>
							<td>
								<form:select path="assetTransactionItemsForm[${status.index}].companyCode">
						 			<form:options items="${globalCompanyCode}" itemValue="systemCode1" itemLabel="systemCodeValueDescription" />
						 		</form:select>
							</td>
							<td>${item.locationName}</td>
							<td ><input name="assetTransactionItemsForm[${status.index}].location.locationId" type="hidden" value="${item.locationId}" /> <input
								name="assetTransactionItemsForm[${status.index}].assetModel.assetModelId" type="hidden" value="${assetModel.assetModelId}" /> <input
								name="assetTransactionItemsForm[${status.index}].assetTransactionQuantity" type="text" value="" /></td>
						</tr>
					</c:forEach>
				</c:otherwise>
			</c:choose>

		</tbody>
	</table>
	<div class="action"><c:choose>
		<c:when test="${assetTransaction.assetTransactionId==null}">
			<button type="submit" class="button positive">Save</button>
			<a href="<c:url value="/assetModel/update/${assetModel.assetModelId}" />" class="button">Back</a>
		</c:when>
		<c:when test="${assetTransaction.assetTransactionId!=null}">
			
			<c:url value="/assetModel/initialBalance/${assetModel.assetModelId}" var="initialBalanceUrl"></c:url>
			<a href="<c:url value="/assetModel/update/${assetModel.assetModelId}" />" class="button">Back</a>

		</c:when>
	</c:choose></div>
</form:form>
<script type="text/javascript">
		$(document).ready(function() {
			
		});
	</script>